package com.study.threadpool;

import java.util.concurrent.*;

/**
 * @Author HBZ
 * @Date 2020/8/5 14:16
 * @Description
 */
public class ThreadTest1 {
    static class  TxTack implements  Runnable{

        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName()+"业务逻辑");
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    public static void method() {
        ExecutorService service=new ThreadPoolExecutor(200,500,60,TimeUnit.SECONDS,new LinkedBlockingDeque<>(200));
        for (int i=0;i<1000;i++){
            service.execute(new TxTack());
        }
        service.shutdown();
    }
    public static void main(String[] args) {
        ExecutorService service=new ThreadPoolExecutor(1,1,60,TimeUnit.SECONDS,new LinkedBlockingQueue<>(10));
        for (int i=0;i<15;i++){
            service.execute(new TxTack());
        }

        service.shutdown();
    }
}
